Telegram Group & Telegram Channel
Forwarded from Python/ django
🐍 Π—Π°Π΄Π°Ρ‡Π° ΠΏΠΎ Python: Замыкания ΠΈ области видимости

Π§Ρ‚ΠΎ Π²Ρ‹Π²Π΅Π΄Π΅Ρ‚ ΡΠ»Π΅Π΄ΡƒΡŽΡ‰ΠΈΠΉ ΠΊΠΎΠ΄?


def outer():
x = 5
def inner():
nonlocal x
x += 1
return x
return inner

f = outer()
print(f())
print(f())
print(f())


Π’Π°Ρ€ΠΈΠ°Π½Ρ‚Ρ‹ ΠΎΡ‚Π²Π΅Ρ‚Π°:
A)

7
8


B)

5
5


C)

6
6


D) Ошибка выполнСния

---

βœ… ΠŸΡ€Π°Π²ΠΈΠ»ΡŒΠ½Ρ‹ΠΉ ΠΎΡ‚Π²Π΅Ρ‚: A

ΠŸΠΎΡ‡Π΅ΠΌΡƒ:
Ѐункция
outer создаёт Π·Π°ΠΌΡ‹ΠΊΠ°Π½ΠΈΠ΅. ΠŸΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½Π°Ρ x сохраняСтся ΠΌΠ΅ΠΆΠ΄Ρƒ Π²Ρ‹Π·ΠΎΠ²Π°ΠΌΠΈ f, ΠΏΠΎΡ‚ΠΎΠΌΡƒ Ρ‡Ρ‚ΠΎ inner β€” Π·Π°ΠΌΡ‹ΠΊΠ°Π΅Ρ‚ x ΠΈ измСняСт Π΅Ρ‘ с ΠΏΠΎΠΌΠΎΡ‰ΡŒΡŽ nonlocal. Π­Ρ‚ΠΎ классичСский ΠΏΡ€ΠΈΠΌΠ΅Ρ€ использования Π·Π°ΠΌΡ‹ΠΊΠ°Π½ΠΈΠΉ Π² Python.

@pythonl



tg-me.com/python_testit/1160
Create:
Last Update:

🐍 Π—Π°Π΄Π°Ρ‡Π° ΠΏΠΎ Python: Замыкания ΠΈ области видимости

Π§Ρ‚ΠΎ Π²Ρ‹Π²Π΅Π΄Π΅Ρ‚ ΡΠ»Π΅Π΄ΡƒΡŽΡ‰ΠΈΠΉ ΠΊΠΎΠ΄?


def outer():
x = 5
def inner():
nonlocal x
x += 1
return x
return inner

f = outer()
print(f())
print(f())
print(f())


Π’Π°Ρ€ΠΈΠ°Π½Ρ‚Ρ‹ ΠΎΡ‚Π²Π΅Ρ‚Π°:
A)

7
8


B)

5
5


C)

6
6


D) Ошибка выполнСния

---

βœ… ΠŸΡ€Π°Π²ΠΈΠ»ΡŒΠ½Ρ‹ΠΉ ΠΎΡ‚Π²Π΅Ρ‚: A

ΠŸΠΎΡ‡Π΅ΠΌΡƒ:
Ѐункция
outer создаёт Π·Π°ΠΌΡ‹ΠΊΠ°Π½ΠΈΠ΅. ΠŸΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½Π°Ρ x сохраняСтся ΠΌΠ΅ΠΆΠ΄Ρƒ Π²Ρ‹Π·ΠΎΠ²Π°ΠΌΠΈ f, ΠΏΠΎΡ‚ΠΎΠΌΡƒ Ρ‡Ρ‚ΠΎ inner β€” Π·Π°ΠΌΡ‹ΠΊΠ°Π΅Ρ‚ x ΠΈ измСняСт Π΅Ρ‘ с ΠΏΠΎΠΌΠΎΡ‰ΡŒΡŽ nonlocal. Π­Ρ‚ΠΎ классичСский ΠΏΡ€ΠΈΠΌΠ΅Ρ€ использования Π·Π°ΠΌΡ‹ΠΊΠ°Π½ΠΈΠΉ Π² Python.

@pythonl

BY Python tests


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/python_testit/1160

View MORE
Open in Telegram


Python tests Telegram | DID YOU KNOW?

Date: |

How Does Bitcoin Mining Work?

Bitcoin mining is the process of adding new transactions to the Bitcoin blockchain. It’s a tough job. People who choose to mine Bitcoin use a process called proof of work, deploying computers in a race to solve mathematical puzzles that verify transactions.To entice miners to keep racing to solve the puzzles and support the overall system, the Bitcoin code rewards miners with new Bitcoins. β€œThis is how new coins are created” and new transactions are added to the blockchain, says Okoro.

The SSE was the first modern stock exchange to open in China, with trading commencing in 1990. It has now grown to become the largest stock exchange in Asia and the third-largest in the world by market capitalization, which stood at RMB 50.6 trillion (US$7.8 trillion) as of September 2021. Stocks (both A-shares and B-shares), bonds, funds, and derivatives are traded on the exchange. The SEE has two trading boards, the Main Board and the Science and Technology Innovation Board, the latter more commonly known as the STAR Market. The Main Board mainly hosts large, well-established Chinese companies and lists both A-shares and B-shares.

Python tests from us


Telegram Python tests
FROM USA